package com.atguigu.c_iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class Demo1 {
    public static void main(String[] args) {
        //创建List集合
        List<String> list = new ArrayList<>();
        System.out.println("list = " + list);//[]

        //添加元素 -> 依次添加
        list.add("张三丰");
        list.add("张翠山");
        list.add("张无忌");

        System.out.println("list = " + list);

        //迭代器
        Iterator<String> it = list.iterator();


        while(it.hasNext()){
            String name = it.next();
            System.out.println("name = " + name);
            if (name.equals("张翠山")){
                list.add("殷素素");
            }
        }

    }
}
